﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using Elderos.Highlight.Search;

namespace Elderos.Highlight
{
    public class WebHighlighter : IHighlighter
    {
        private ChannelFactory<IHighlighter> _factory;

        public WebHighlighter(string endpointName)
        {
            _factory = new ChannelFactory<IHighlighter>(endpointName);
        }

        public List<Position> Search(string text)
        {
            var client = _factory.CreateChannel();
            var result = client.Search(text);
            return result;
        }

        public HighlightResult Highlight(string text)
        {
            var client = _factory.CreateChannel();
            return client.Highlight(text);
        }

        public ArticleHighlight ProcessArticle(string text)
        {
            var client = _factory.CreateChannel();
            return client.ProcessArticle(text);
        }
    }
}